package example.chapter12.subset;

import java.util.ArrayList;
import java.util.List;

import org.apache.struts2.util.SubsetIteratorFilter.Decider;

import com.opensymphony.xwork2.ActionSupport;

public class SubsetTagAction extends ActionSupport{
	private List<Integer> myList;
	
	public String execute() throws Exception{
		myList = new ArrayList<Integer>();
		myList.add(new Integer(1));
		myList.add(new Integer(2));
		myList.add(new Integer(3));
		myList.add(new Integer(4));
		myList.add(new Integer(5));
		
		return SUCCESS;
	}
	
	public Decider getMyDecider(){
		return new Decider(){
			public boolean decide(Object element) throws Exception{
				int i = ((Integer)element).intValue();
				return(i%2 == 0) ? true : false;
			}
		};
	}

	public List<Integer> getMyList() {
		return myList;
	}

	public void setMyList(List<Integer> myList) {
		this.myList = myList;
	}
	
}
